<?php
/**
* Django's templating engine (partial) PHP implementation
* @link http://djangoproject.com Django
* this file is from a webappkit package (kit)
* @link http://webappkit.net
* @package djtpl
* @author J.Ducastel <jeremie@ducastel.name>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

/**
* generic node tag
* use only static methods, unless tag is undefined
*/
class djtplTagNode extends djtplNode {

	/**
	* render to string
	* @access public
	* @return string
	*/
	function render(&$context) {
		return '<!-- unsupported tag : '.$this->getTagName().' -->'
		.($this->isAtomic()?'':
			$this->renderChildNodes($context));
	}/**/

	/**
	* builds itself from tokens
	* @param djangoTplToken &$selfToken
	* @param array &$nextTokens djangoTplToken
	* @access public
	* @return bool
	*/
	function buildFromTokens(&$selfToken, &$nextTokens) {
		//$this->token=&$selfToken;
		$this->tagname=$selfToken->getTagName();
		$this->tagdef=$selfToken->getTagDef();
		// building child nodes
		$this->buildChildNodesFromTokens($nextTokens);
		return true;
	}/**/

	/**
	* return own tag name
	* @access public
	* @return string
	*/
	function getTagName() {
		return $this->tagname;
		// class name minus 'djtplTagNode_''
		//$tagname=substr(get_class($this),17); echo " [$tagname] ";
		return $tagname;
	}/**/

	/**
	* @var string tag name
	*/
	var $tagname;

	/**
	* loops tokens array until ending tag, build child nodes
	*
	* @param array &$tokens
	* @access protected
	* @return bool
	*/
	function buildChildNodesFromTokens(&$tokens) {
		//echo $this->getTagName().' building child nodes<br />';
		if ($this->isAtomic())
			return false;
		// expected end tag name ?
		$endtag='end'.$this->getTagName();
		// looping
		$this->childnodes=djtplParser::tokensToNodesUntilTag($tokens,$endtag);
		return true;
	}/**/
} /* end of djtplTagNode class */
?>